home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / djsvga.trm < prev    next >
Text File  |  1993-09-15  |  3KB  |  130 lines

  1. /*
  2.  * $Id: djsvga.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  3.  */
  4.  
  5. /* GNUPLOT - djsvga.trm */
  6. /*
  7.  * Copyright (C) 1992
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  *
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports:
  24.  *  svga
  25.  *
  26.  * AUTHORS
  27.  *  Russell Lang
  28.  *
  29.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  30.  *
  31.  */
  32.  
  33. /* SVGA driver using DJGPP */
  34. #include <graphics.h>
  35. #include <pc.h>
  36.  
  37. int dj_startx, dj_starty;
  38. int dj_xlast, dj_ylast;
  39. int dj_color;
  40.  
  41. #define DJSVGA_XMAX 640
  42. #define DJSVGA_YMAX 480
  43.  
  44. #define DJSVGA_XLAST (DJSVGA_XMAX - 1)
  45. #define DJSVGA_YLAST (DJSVGA_YMAX - 1)
  46.  
  47. #define DJSVGA_VCHAR 16
  48. #define DJSVGA_HCHAR 8
  49. #define DJSVGA_VTIC 4
  50. #define DJSVGA_HTIC 4
  51.  
  52. #define DJNUMCOLOR 15
  53. static int svga256color[DJNUMCOLOR] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  54. static int dj_colors[DJNUMCOLOR];
  55.  
  56.  
  57. DJSVGA_init()
  58. {
  59. int i, on, r, g, b;
  60.     /* Allocate colors */
  61.     for (i=0; i<DJNUMCOLOR; i++) {
  62.         on = svga256color[i] & 8 ? 255 : 170;
  63.         r  = svga256color[i] & 4 ? on : 0;
  64.         g  = svga256color[i] & 2 ? on : 0;
  65.         b  = svga256color[i] & 1 ? on : 0;
  66.         if (svga256color[i] == 8) r=g=b=85;
  67.         dj_colors[i] = GrAllocColor(r,g,b);
  68.     }
  69.     /* Get the screen size: */
  70.     GrSetMode(GR_default_graphics,0,0); /* */
  71.     dj_xlast = GrMaxX();
  72.         term_tbl[term].xmax = dj_xlast + 1;
  73.     dj_ylast = GrMaxY();
  74.         term_tbl[term].ymax = dj_ylast + 1;
  75.     GrSetMode(GR_default_text,0,0); /* */
  76. }
  77.  
  78. DJSVGA_graphics()
  79. {
  80.     GrSetMode(GR_default_graphics,0,0);
  81. }
  82.  
  83. DJSVGA_text()
  84. {
  85.     (void)getkey();
  86.     GrSetMode(GR_default_text,0,0);
  87. }
  88.  
  89. DJSVGA_reset()
  90. {
  91. int i;
  92.     /* Free colors */
  93.     for (i=0; i<DJNUMCOLOR; i++) {
  94.         GrFreeColor(dj_colors[i]);
  95.     }
  96. }
  97.  
  98. DJSVGA_linetype(linetype)
  99. int linetype;
  100. {
  101.     if (linetype >= 13)
  102.         linetype %= 13;
  103.     dj_color = dj_colors[linetype+2];
  104. }
  105.  
  106. DJSVGA_move(x,y)
  107. unsigned int x,y;
  108. {
  109.     dj_startx = x;
  110.     dj_starty = y;
  111. }
  112.  
  113.  
  114. DJSVGA_vector(x,y)
  115. unsigned int x,y;
  116. {
  117.     GrLine(dj_startx,dj_ylast-dj_starty,x,dj_ylast-y,dj_color);
  118.     dj_startx = x;
  119.     dj_starty = y;
  120. }
  121.  
  122.  
  123. DJSVGA_put_text(x,y,str)
  124. unsigned int x, y;
  125. char *str;
  126. {
  127.     GrTextXY(x,dj_ylast-y-DJSVGA_VCHAR/2,str,dj_color,GrNOCOLOR);
  128. }
  129.  
  130.